#include <iostream>
using namespace std;

int main()
{
    int a=0;
    string s1="";
    string str;
    cout<<"Введите строку:"<<endl;
    cin>>str;
    
    for(int i=0;i<str.size(); i++)
    {
        if(str[i]=='(' or str[i]=='[' or str[i]=='{' or str[i]=='<')
        {
            s1+=str[i];
        }
        
        if(str[i]==')'){
            if(s1[s1.size()-1] == '('){
                s1.pop_back();
            }
            else{
                a=1;
                break;
            }
        }
        
        if(str[i]=='}'){
            if(s1[s1.size()-1] == '{'){
                s1.pop_back();
            }
            else{
                a=1;
                break;
            }
        }
        if(str[i]==']'){
            if(s1[s1.size()-1] == '['){
                s1.pop_back();
            }
            else{
                a=1;
                break;
            }
        }
        if(str[i]=='>'){
            if(s1[s1.size()-1] == '<'){
                s1.pop_back();
            }
            else{
                a=1;
                break;
            }
        }
}
    if (a==0 and s1.size()==0)
    {
        cout<<"True";
    }
        else
        {
            cout<<"False";
        }
        
        return 0;

}